package com.examsystem.service.impl;

import com.examsystem.dao.UserClassMapper;
import com.examsystem.pojo.UserClass;
import com.examsystem.service.UserClassService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

import static com.examsystem.Const.ConstMsg.SUBMIT_CLASS_FAIL_MSG;

/**
 * @author fire'ge
 */
@Service("userClassService")
public class UserClassServiceImpl implements UserClassService {
    @Resource
    UserClassMapper userClassMapper;
    @Override
    public void addUserClass(int userId, int classId) {
        UserClass userClass = new UserClass();
        userClass.setUcClass(classId);
        userClass.setUcUser(userId);
        int add = userClassMapper.addUserClass(userClass);
        if (add == 0){
            throw new RuntimeException(SUBMIT_CLASS_FAIL_MSG);
        }
    }
}
